<template>
	<view class="content">
		<uni-nav-bar title="新增工单" left-icon="back" @clickLeft="back">
		</uni-nav-bar>
		<view class="middle-content">
			<swiper class="swiper" :current="0" :duration="300">
				<swiper-item>
					<scroll-view scroll-y="true" class="scroll-Y flex flex-col">
						<view class="order-item flex align-center">
							<view class="stauts margin-right-sm">{{ orderDetails.status }}</view>
							<view>></view>
						</view>
						<view class="order-item">
							<view class="flex align-center">
								<image src="/static/images/shop.png" class="image-info" />
								<view class="stauts">门店信息</view>
							</view>
							<view class="line"></view>
							<view class="flex margin-bottom-sm">
								<view class="name">所属门店：</view>
								<view>{{orderDetails.orderId}}</view>
							</view>
							<view class="flex margin-bottom-sm">
								<view class="name">联 系 人：</view>
								<view>{{orderDetails.device}}</view>
							</view>
							<view class="flex margin-bottom-sm">
								<view class="name">联系电话：</view>
								<view>{{orderDetails.address}}</view>
							</view>
							<view class="flex margin-bottom-sm">
								<view class="name">门店地址：</view>
								<view>{{orderDetails.address}}</view>
							</view>
						</view>
						<view class="order-item">
							<view class="flex align-center">
								<image src="/static/images/common.png" class="image-info" />
								<view class="stauts">基本信息</view>
							</view>
							<view class="line"></view>
							<view class="flex margin-bottom-sm">
								<view class="name">订单类型：</view>
								<view>{{orderDetails.orderId}}</view>
							</view>
							<view class="flex margin-bottom-sm">
								<view class="name">设备类型：</view>
								<view>{{orderDetails.device}}</view>
							</view>
							<view class="flex margin-bottom-sm">
								<view class="name">问题描述：</view>
								<view>{{orderDetails.address}}</view>
							</view>
							<view class="flex margin-bottom-sm">
								<view class="name">门店地址：</view>
								<view>{{orderDetails.address}}</view>
							</view>
						</view>
						<view class="order-item">
							<view class="flex align-center">
								<image src="/static/images/workOrder.png" class="image-info" />
								<view class="stauts">工单信息</view>
							</view>
							<view class="line"></view>
							<view class="flex margin-bottom-sm">
								<view class="name">订单类型：</view>
								<view>{{orderDetails.orderId}}</view>
							</view>
							<view class="flex margin-bottom-sm">
								<view class="name">设备类型：</view>
								<view>{{orderDetails.device}}</view>
							</view>
							<view class="flex margin-bottom-sm">
								<view class="name">问题描述：</view>
								<view>{{orderDetails.address}}</view>
							</view>
							<view class="flex margin-bottom-sm">
								<view class="name">门店地址：</view>
								<view>{{orderDetails.address}}</view>
							</view>
						</view>
						<view class="order-item">
							<view class="flex align-center">
								<image src="/static/images/repair.png" class="image-info" />
								<view class="stauts">维修信息</view>
							</view>
							<view class="line"></view>
							<view class="flex margin-bottom-sm">
								<view class="name">维修师傅：</view>
								<view>{{orderDetails.orderId}}</view>
							</view>
							<view class="flex margin-bottom-sm">
								<view class="name">联系电话：</view>
								<view>{{orderDetails.device}}</view>
							</view>
						</view>
					</scroll-view>

				</swiper-item>
			</swiper>
			<view class="action-btn">
				<button @click="cancelWorkOrder" type="default" class="round">取消工单</button>
				<!-- <button @click="cancelWorkOrder" type="default" class="round">确认工单</button> -->
			</view>
		</view>
		<uni-popup ref="cancelDialog" type="dialog" :mask-click="false">
			<uni-popup-dialog cancelText="取消" confirmText="确定" title="提示" content="是否确定取消工单？"
				@confirm="cancelWorkOrderConfirm" @close="dialogClose"></uni-popup-dialog>
		</uni-popup>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				orderDetails: {
					name: '测试工单',
					status: '待处理',
					orderName: '测试工单',
					orderId: 'WX2024060512120001',
					type: '',
					address: '山西临汾市洪洞县涧桥南路',
					device: '奶茶机',
					deviceType: '设备安装',
				},
			}
		},
		methods: {
			handleClick(data) {
				this.orderQueryParams.status = data
				this.activeValue = data
				this.getorderlist()
			},
			getorderlist() {
				this.orderList = [{
					name: '测试工单11',
					status: '待处理',
					orderName: '测试工单',
					orderId: 'WX2024060512120001',
					type: '',
					address: '山西临汾市洪洞县涧桥南路',
					device: '奶茶机',
					deviceType: '设备安装',
				}]
			},
			back() {
				uni.navigateBack();
			},
			reachBottom() {
				console.log('refresherrefresh')
			},
			goDetaiPage(item) {
				uni.navigateTo({
					url: `/pages/workOrder/detail?orderId=${item.orderId}`,
				})
			},
			cancelWorkOrderConfirm() {
				console.log('点击确认')
			},
			dialogClose() {
				this.$refs.cancelDialog.close()
			},
			cancelWorkOrder() {
				this.$refs.cancelDialog.open()
			},
		}
	}
</script>

<style lang="scss">
	page {
		height: 100%;
	}

	.content {
		height: 100%;
		display: flex;
		flex-direction: column;

		.middle-content {
			padding: 20rpx 30rpx 10rpx 30rpx;
			flex: 1;
			display: flex;
			flex-direction: column;
			justify-content: space-between;

			.swiper {
				padding-bottom: 30rpx;
				flex: 1;
			}

			.scroll-Y {
				height: 100%;
			}

			.stauts {
				font-size: 32rpx;
				font-weight: 600;
			}

			.order-item {
				background: #FFFFFF;
				border-radius: 15rpx;
				margin-bottom: 20rpx;

				padding: 20rpx;
			}

			.line {
				position: relative;
				height: 1px;
				background-color: #e2dfdf;
				margin: 20rpx 0;
			}

			.line::after {
				content: '';
				position: absolute;
				left: 0;
				top: 0;
				width: 100%;
				height: 1px;
				background-color: #e2dfdf;
				transform: scaleY(1);
				transform-origin: 0 0;
			}

			.name {
				font-size: 28rpx;
				color: #9097AA;
			}

			.image-info {
				width: 30rpx;
				height: 30rpx;
				margin-right: 10rpx;
			}
		}
	}
</style>